<template>
  <div @click="clickHandler">
    <Background v-show="showUpload" id="upload-background"></Background>
    <div id="my-dialog">
      <div id="title">{{ title }}</div>
      <slot></slot>
    </div>
  </div>
</template>

<script>

import Background from "@/components/background";
import {mapActions, mapState} from "vuex";

export default {
  name: "my-dialog",
  components: {Background},
  props: ['title'],
  methods: {
    ...mapState(['showUpload']),
    ...mapActions(['setShowUpload']),
    clickHandler(e) {
      if (e.target.id === 'upload-background') {
        this.setShowUpload(false)
      }
    }
  }
}
</script>

<style scoped>
#my-dialog {
  position: fixed;
  left: 15%;
  width: 70%;
  background: white;
  border-radius: 10px;
  padding: 20px;
  z-index: 1000;
}
</style>